#include "service_mode_impl.h"
void ServiceModeImpl::load(vector<Department>& dpm)
{	
	ifstream ifs("services.dat");
	if(!ifs.is_open())
	{
		cout << "打开失败!" << endl;
		return;
	}
	//vector<Department>:: iterator it = dpm.begin();
	while(true)
	{
		Department* dp = new Department;
		ifs >> *dp;
		if(!ifs.good())
		{
			//delete dp;
			break;
		}
		dpm.push_back(*dp);
	}
	ifs.close();
}
void ServiceModeImpl::save(vector<Department>& dpm)
{
	ofstream ofs("services.dat");
	if(!ofs.is_open())
	{
		cout << "打开失败!" << endl;
		return;
	}
	vector<Department>::iterator it = dpm.begin();
	for(int i=0;i<dpm.size();i++)
	{
		ofs << dpm[i];
	}
	
	ofs.close();
}
